﻿<!--
//初始化
function toStart()
{
    var tr = document.getElementById("trRole");
    var rbls = document.getElementsByName("rblTypeID");
    
    if(rbls[2].checked)
        tr.style.display = "";
    else
        tr.style.display = "none";
}

//添加
function Add()
{
    var lb1 = document.getElementById("lb1");
    var lb2 = document.getElementById("lb2");
    var v = lb1.value;
    var i = 0, isCheck = false;
    for (;i<lb1.length; i++)
    {
        if(lb1.options[i].value == v)
        {
            isCheck = true;
            break;
        }
    }
    if(!isCheck)      //判断是否已经选定
        return false;
        
    for (var j=0;j<lb2.length;j++)
    {
        //判断是否已经存在
        if(lb2.options[j].value == v)
            return false;
    }
    
    //追加
    lb2.length++;
    lb2.options[lb2.length-1].value = v;
    lb2.options[lb2.length-1].text = lb1.options[i].text;
    
    tempSave();

    return false;
}

//删除
function Delete()
{
    var lb2 = document.getElementById("lb2");
    var v = lb2.value;
    for (var i = 0;i<lb2.length; i++)
    {
        if(lb2.options[i].value == v)
        {
            lb2.remove(i);
            
            tempSave();
            break;
        }
    }
    
    return false;
}

//临时保存
function tempSave()
{
    var hf2 = document.getElementById("hf2");
    hf2.value = "";
    
    var lb2 = document.getElementById("lb2");
    for(var i=0;i<lb2.length;i++)
    {
        hf2.value += lb2.options[i].value + ",";
    }
    
    if(hf2.value != "")
        hf2.value = hf2.value.substring(0, hf2.value.length - 1);
}

//-->